package com.exsun.ex1077.network.entity

import com.amap.api.maps.model.LatLng
import com.zhangping.fastjetpack.extend.toDate
import com.zhangping.fastjetpack.utils.JZLocationConverter

data class VehicleTrackSocket(
    var lat: Double = 0.0,
    var lng: Double = 0.0,
    val spd: Int = 0,
    val gdt: String = "",
    val dre: Int = 0,
    val poi: Poi? = null,
    val dvo: String = "",
){
    fun isVehicleOnline(): Boolean{
        if (gdt.isNullOrEmpty()) return false
        return System.currentTimeMillis() - gdt.toDate().time <= 5 * 60 * 1000
    }

    fun wgs84ToGcj02(){
        val newLatLng = JZLocationConverter.wgs84ToGcj02(JZLocationConverter.LatLng(lat, lng))
        lat = newLatLng.latitude
        lng = newLatLng.longitude
    }

    fun getLatLng() = LatLng(lat, lng)
}